package com.hellomvp.client.activity;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.hellomvp.client.ClientFactory;
import com.hellomvp.client.ui.HelloRightPanel;
import com.hellomvp.client.place.HelloPlace;

public class RightPanelHelloActivity extends AbstractActivity {
	private ClientFactory clientFactory;
	private String name; //name that will be appended to "Hello "
	
	public RightPanelHelloActivity(HelloPlace place, ClientFactory clientFactory) {
		this.name = place.getHelloName();
		this.clientFactory = clientFactory;
	}
	
	/**
	 * Invoked by the ActivityManager to start a new Activity
	 */
	@Override
	public void start(AcceptsOneWidget panel, EventBus eventBus) {
		HelloRightPanel helloRightPanel = clientFactory.getHelloRightPanel();
		helloRightPanel.setName(name);
		panel.setWidget(helloRightPanel.asWidget());
	}
	
	/**
	 * Ask user before stopping this activity
	 */
	@Override
	public String mayStop() {
		return "Please hold on. This activity is stopping.";
	}
}
